#ifndef _PARTICLE_H_
#define _PARTICLE_H_

#include <QList>
#include <cstring>
#include <cmath>
#include "neuralnetwork.h"

class Particle 
{
   friend class Pso;
   
  public:
    Particle();
    ~Particle();
    void setNeuralNetwork( const NeuralNetwork &ann );
    
    void setX( float x, int d ); // undefined behaviour on d out of range
    void setV( float v, int d );
    void setPbest( float best );
    void setPbestx( float x, int d );
    
    float fitness( const QList< QList< float > > &inputList, const QList< QList< float > > &outputList );
    float fitness( const QList< float > &input, const QList< float > &target );
    float fitness( const QList< float > &error );
    
    int dimension();
    float x( int d ); // undefined behaviour on d out of range
    float v( int d );
    float pbest();
    float pbestx( int d );
    
  private:
    NeuralNetwork m_ann;
    
    QList< float > m_v;
    float m_pbest;
    QList< float > m_pbestx;
};

#endif
